package com.sino.operation.service.business;

import com.sino.operation.config.Spring.SpringContextUtils;
import com.sino.operation.entity.BizOperateLog;
import com.sino.operation.mapper.*;
import com.sino.operation.param.inner.TaskBackParam;
import com.sino.operation.param.inner.TaskChoiceOtherParam;
import com.sino.operation.param.inner.TaskTerminalParam;
import com.sino.operation.param.out.EscReceiveByCounterToAccount;
import com.sino.operation.service.business.inter.AccountChargeService;
import com.sino.operation.service.business.inter.ITransactionHandler;
import com.sino.operation.service.core.CoreService;
import com.sino.operation.service.core.entity.PostCoreRecive;
import com.sino.operation.service.manage.ManageService;
import com.sino.operation.util.PersistenceUtil;
import com.sino.operation.entity.BizTranslist;
import com.sino.operation.entity.SysAbMessage;
import com.sino.operation.param.out.EscReciveByCounter;
import com.sino.operation.param.inner.TaskCompleteParam;
import com.sino.operation.util.RestTemplateUtils;
import com.sino.operation.util.UrlUtil;
import lombok.Data;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.Map;

/**
 * TOD
 *
 * @author Administrator
 * date 2021/10/16 0016 14:53
 */
@Data
public abstract class BaseAction implements ITransactionHandler {

    /**
     * 业务流水号
     */
    protected String journalNo;

    /**
     * 返回的持久化器
     */
    protected PersistenceUtil persistence;

    /**
     * 交易登记簿表
     */
    protected Object registerTable = null;

    /**
     * 操作日志表
     */
    protected BizOperateLog bizOperateLog;

    /**
     * 接收的参数类
     */
    protected Object receiveParam = null;

    /**
     * 流水表对象
     */
    protected BizTranslist bizTranslist;

    /**
     * 参数报表
     */
    protected SysAbMessage sysAbMessage;

    /**
     * 传入工作流集合
     */
    protected Map varMap;

    /**
     * 接收柜面的发起交易参数
     */
    protected EscReciveByCounter escReciveByCounter;

    /**
     * 接收柜面发起的开变销交易参数
     */
    protected EscReceiveByCounterToAccount escReceiveByCounterToAccount;

    /**
     * 任务提交参数
     */
    protected TaskCompleteParam taskCompleteParam;

    /**
     * 任务暂挂、解挂、释放参数
     */
    protected TaskChoiceOtherParam taskChoiceOtherParam;

    /**
     * 任务回退参数
     */
    protected TaskBackParam taskBackParam;

    /**
     * 任务终止参数参数
     */
    protected TaskTerminalParam taskTerminalParam;

    /**
     * 创建bean工具
     */
    protected ApplicationContext applicationContext = SpringContextUtils.getApplicationContext();

    /**
     * 字段配置mapper
     */
    protected BizDictSetMapper bizDictSetMapper = this.applicationContext.getBean(BizDictSetMapper.class);

    /**
     * 账管登记簿mapper
     */
    protected BizAccountmanageInfoMapper accountmanageInfoMapper = this.applicationContext.getBean(BizAccountmanageInfoMapper.class);

    /**
     * 普通汇兑登记簿mapper
     */
    protected BizExchangeInfoMapper bizExchangeInfoMapper = this.applicationContext.getBean(BizExchangeInfoMapper.class);
    /**
     * 行内转账登记簿mapper
     */
    protected BizInternalTransMapper bizInternalTransMapper = this.applicationContext.getBean(BizInternalTransMapper.class);
    /**
     * 保证金登记簿mapper
     */
    protected BizMarginOpenAccountMapper bizMarginOpenAccountMapper = this.applicationContext.getBean(BizMarginOpenAccountMapper.class);

    /**
     * 定期（通知）存款mapper
     */
    protected BizDespositInfoMapper bizDespositInfoMapper = this.applicationContext.getBean(BizDespositInfoMapper.class);

    /**
     * 记账执行的mapper
     */
    protected BizChargeMethodsMapper bizChargeMethodsMapper = this.applicationContext.getBean(BizChargeMethodsMapper.class);

    /**
     * redis
     */
    protected StringRedisTemplate redis = this.applicationContext.getBean(StringRedisTemplate.class);

    /**
     * 报表mapper
     */
    protected SysAbMessageMapper sysAbMessageMapper = this.applicationContext.getBean(SysAbMessageMapper.class);

    /**
     * 交易管理表mapper
     */
    protected BizManagerTransMapper bizManagerTransMapper = this.applicationContext.getBean(BizManagerTransMapper.class);

    /**
     * 寻址工具类
     */
    protected UrlUtil urlUtil = this.applicationContext.getBean(UrlUtil.class);

    /**
     * restTemplete工具类
     */
    protected RestTemplateUtils restTemplateUtils = this.applicationContext.getBean(RestTemplateUtils.class);

    /**
     * 开变销记账业务类
     */
    protected AccountChargeService accountChargeService = this.applicationContext.getBean(AccountChargeService.class);

    /**
     * 保证金、
     */
    protected AccountChargeService2 accountChargeService2 = this.applicationContext.getBean(AccountChargeService2.class);

    /**获取开变销所有字段的集合业务类*/
    protected AccountStartTest accountStartTest=this.applicationContext.getBean(AccountStartTest.class);

    /**获取发往核心参数类业务*/
    protected ObtainEscCoreParamService obtainEscCoreParamService=this.applicationContext.getBean(ObtainEscCoreParamService.class);

    /**对公活期建立客户信息业务类*/
    protected CoreService coreService =this.applicationContext.getBean(CoreService.class);

    /**账管报备业务类*/
    protected ManageService manageService=this.applicationContext.getBean(ManageService.class);

    public BaseAction(Map varMap, BizTranslist bizTranslist, SysAbMessage sysAbMessage, BizOperateLog bizOperateLog, Object registerTable, Object receiveParam) {
        this.persistence = new PersistenceUtil();
        this.bizTranslist = bizTranslist;
        this.sysAbMessage = sysAbMessage;
        this.varMap = varMap;
        this.bizOperateLog = bizOperateLog;
        this.registerTable = registerTable;
        this.receiveParam = receiveParam;
    }

    public BaseAction(String journalNo, SysAbMessage sysAbMessage) {
        this.journalNo = journalNo;
        this.sysAbMessage = sysAbMessage;
    }
}
